
# Automan

Initially, this project was meant as an wrapper around `man` that offered
automatic text reflow. The idea behind it was to recompile the source document
on receiving a `SIGWINCH`. While that is indeed possible, and the current script
currently works, still there is no simple to way to merely restore the previous
position on the document.

We can get kind close to this by abusing a behaviour of `less`: it stores the
last position of the last closed document in `.lesshst`. I abuse this to restore
the previous position of in the manual page, but this won't work if we are
dealing with multiple documents. Further, this is not even an perfect solution,
as the terminal width changes, so does the last position the reader was in. To
workaround this issue, we would need to know how `less` does its position
calcualtion. A cursory look at the source code does not have any obvious
solution.

I could attempt to hack around this using `tmux`. The idea would be to send key
presses to mark the pages in `less` (this would also require that the
`--save-marks` option to be set). Then the script should restart the current
`less` instance and then send some more key presses to restore the previous
page.

This approach has some issues. First, it doesn't scale. The user would be
limited to 50 pages that with text reflow (`less` only allow marks on the ranges
[a-zA-z]). Second, and most damming, since we can't know on which of the
pages the user stopped (`less` offers to mechanism to work around this) when the
reflows occurs, we can't neither properly restore to the user to where she was,
nor correcly know when to stop applying the marks.

The only way around this issues is directly hacking on `less` to make it more
scriptable, as it stands, is probably better to use an alternate strategy to
have `man` pages that automatically reflow and offer other quality of life
feautures.
